/* 
 * File:   ListOfConquests.cpp
 * Author: camenesesg
 *
 * Created on August 25, 2013, 5:01 PM
 */
#include <cstdlib>
#include <cstdio>
#include <ctime>
#include <map>
#include <set>
#include <string>

using namespace std;

/*
 * 
 */
int mainListOfConquests() {
#ifndef ONLINE_JUDGE
    FILE * FILE_NAME = freopen("inListOfConquests.txt", "rt", stdin);
    int TIME = clock();
#endif
    int n;
    char country[80], mara_momes[80];
    if (scanf("%d\n", &n) == 1) {
        map<string, int> m;
        while (n-- && scanf("%s", country) == 1 && gets(mara_momes)) {
            m[string(country)] = m[string(country)] + 1;
        }
        for (map<string, int>::iterator it = m.begin(); it != m.end(); it++) {
            printf("%s %d\n", it->first.c_str(), it->second);
        }
    }
    
#ifndef ONLINE_JUDGE
    printf("%f\n", ((float) (clock() - TIME)));
    fclose(FILE_NAME);
#endif
    return EXIT_SUCCESS;
}
